from selenium.webdriver.common.by import By
from tests.pages.web_page.base_page import BasePage

class LoginPage(BasePage):
    SEARCH_BOX_USERNAME = (By.NAME, 'email')
    SEARCH_BOX_PASSWORD = (By.NAME, 'password')
    SEARCH_BUTTON = (By.ID, 'dologin')
    Iframe = (By.XPATH,'//iframe[contains(@src, "dl.reg.163.com/webzj")]')

    def enter_search_term(self, type, term):
        if type == 'username':
            self.enter_text(self.SEARCH_BOX_USERNAME,term)
        elif type == 'password':
            self.enter_text(self.SEARCH_BOX_PASSWORD, term)

    def click_search(self):
        self.click_element(self.SEARCH_BUTTON)

    def login_cd_iframe(self):
        self.cd_iframe(self.Iframe)
